package com.com.lease.web.app.listener;

import com.com.lease.web.app.service.BrowsingHistoryService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BrowsingHistoryListener {

    @Autowired
    private BrowsingHistoryService browsingHistoryService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "browsing.history.queue",durable = "true"),
            exchange = @Exchange(name = "browsing.history.direct"),
            key = "browsing.history"
    ))
    public void listenBrowsingHistory(Long[] arr){
        System.out.println("收到消息");
        browsingHistoryService.saveHistory(arr[0],arr[1]);
    }
}
